var last_page
var videotype = '1'
var titlestr = '推荐'
console.log('开始')
module.exports = {
  type: 'list',
  title: '秋葵->类型选择',
  actions: [
    {
      title: '偷拍自拍',
      onClick: async function () {
        videotype = '10'
        this.refresh()
      }
    },
    {
      title: '人妻熟女',
      onClick: async function () {
        videotype = '6'
        this.refresh()
      }
    },
    {
      title: '高清无码',
      onClick: async function () {
        videotype = '1'
        this.refresh()
      }
    },
    {
      title: '制服诱惑',
      onClick: async function () {
        videotype = '5'
        this.refresh()
      }
    },
    {
      title: '中文字幕',
      onClick: async function () {
        videotype = '19'
        this.refresh()
      }
    },
    {
      title: '网红主播',
      onClick: async function () {
        videotype = '34'
        this.refresh()
      }
    },
    {
      title: '强奸轮奸',
      onClick: async function () {
        videotype = '18'
        this.refresh()
      }
    },
    {
      title: '三级电影',
      onClick: async function () {
        videotype = '25'
        this.refresh()
      }
    },
    {
      title: '欧美AV',
      onClick: async function () {
        videotype = '16'
        this.refresh()
      }
    }
  ],
  searchRoute: $route('list'),
  async fetch({ args, page }) {
    console.log(titlestr)
    var resp
    if (page == null) {
      resp = await $http.get(
        `http://api.klpqk.com/api/videosort/` +
          videotype +
          `?orderby=new&page=1&uuid=48cf2ce1d253e8ee&device=0`
      )
      last_page = resp.data.rescont.last_page
      //console.log(typeof last_page + last_page)
    } else {
      if (page <= last_page) {
        resp = await $http.get(
          `http://api.klpqk.com/api/videosort/` +
            videotype +
            `?orderby=new&page=${page || 1}&uuid=48cf2ce1d253e8ee&device=0`
        )
        //console.log(typeof last_page + last_page +"xiangmu2")
      } else if (page == last_page) {
        $ui.toast('最后一页了')
      } else {
        console.log(page + '超过已有数据 勿刷新！！！')
      }
    }
    if (resp != null) {
      var itmes = resp.data.rescont.data.map(data => ({
        style: 'live',
        title: data.title,
        image: data.coverpath,

        onClick: async item => {
          let res = await $http.get(
            'http://api.klpqk.com/api/videoplay/' +
              data.id +
              '?uuid=48cf2ce1d253e8ee'
          )

          $router.to(
            $route('DSF', {
              title: item.title,
              httpCR: res.data.rescont.videopath,
              img: data.coverpath
            })
          )
        }
      }))
      return {
        nextPage: (page || 1) + 1,
        items: itmes
      }
    }
  }
}
